<style lang="less">
    @import '../../styles/common.less';
    @import '../tables/components/table.less';
</style>
<template>
    <div>
        <Form  :label-width="100" style="height: 38px;margin: 5px 0">
            <Input v-model="sellerName"   placeholder="请输入卖家名" style="width: 200px;margin-right: 3px;float: left"></Input>
            <Input v-model="buyerName"   placeholder="请输入买家名" style="width: 200px;margin-right: 3px;float: left"></Input>
            <Input v-model="count"   placeholder="请输入最小数量" style="width: 200px;margin-right: 3px;float: left"></Input>
            <Input v-model="totalPrice"   placeholder="请输入最小金额" style="width: 200px;margin-right: 3px;float: left"></Input>
            <DatePicker v-model="time" type="datetime" placeholder="请输入最小时间" style="width: 200px"></DatePicker>
            <div style="float: right">
            <Button type="info" style="float: right;margin-right: 5px" @click="load(1)">查询</Button>
            </div>
        </Form>
        <Table :loading="loading" refs="table1"  :data="Message" :columns="columnsList"></Table>
        <Page :total="pageNum" :page-size="pageSize"  style="text-align: center;margin-top: 15px;" show-total @on-page-size-change='pageSizes'  show-elevator show-sizer @on-change="pageChange"></Page>

    </div>
</template>
<script>
    import $http from '../../utils/axiosWrap'
    import canEditTable from '../tables/components/canEditTable.vue'
    export default {
        data() {
            return {
                phone:'',
                loading: true,
                Message:[],
                admin:true,
                columnsList: [
                    {
                        title: '序号',
                        width: 80,
                        align: 'center',
                        render: (h, params) => {
                            return  params.index + (this.initPage- 1) * this.pageSize + 1
                        }
                    },
                    {
                        title: '订单ID',
                        align: 'center',
                        key: 'id',
                        editable: true
                    },
                    {
                        title: '卖家名',
                        align: 'center',
                        key: 'sellerName',
                        editable: true
                    },
                    {
                        title: '买家名',
                        align: 'center',
                        key: 'buyerName',
                        editable: true
                    },
//                    {
//                        title: '卖家手机',
//                        align: 'center',
//                        key: 'sellerTelephone',
//                        editable: true
//                    },
//                    {
//                        title: '买家手机',
//                        align: 'center',
//                        key: 'buyerTelephone',
//                        editable: true
//                    },
                    {
                        title: '价格',
                        align: 'center',
                        key: 'price',
                        editable: true
                    },
                    {
                        title: '数量',
                        align: 'center',
                        key: 'count',
                        editable: true
                    },
                    {
                        title: '总金额',
                        align: 'center',
                        key: 'totalPrice',
                        editable: true
                    },
//                    {
//                        title: '支付方式',
//                        align: 'center',
//                        key: 'payMethod',
//                        editable: true
//                    },
//                    {
//                        title: '支付宝账户',
//                        align: 'center',
//                        key: 'alipay',
//                        editable: true
//                    },
//                    {
//                        title: '银行',
//                        align: 'center',
//                        key: 'bank',
//                        editable: true
//                    },
//                    {
//                        title: '支行',
//                        align: 'center',
//                        key: 'bankBranch',
//                        editable: true
//                    },
//                    {
//                        title: '银行卡号',
//                        align: 'center',
//                        key: 'bankVard',
//                        editable: true
//                    },
//                    {
//                        title: '订单状态',
//                        align: 'center',
//                        key: 'orderStatus',
//                        editable: true
//                    },
                    {
                        title: '完成时间',
                        align: 'center',
                        width: 160,
                        render: (h, params) => {
                            if(params.row.time){
                                return params.row.time.replace(/\T/g, ' ').substring(0,19)
                            }else{
                                return ''
                            }
                        }
                    }
                ],
                sellerName: '',
                buyerName: '',
                time: '',
                count: '',
                totalPrice: '',
                pageNum:0,
                initPage:1,
                pageSize:10
            }
        },
        created: function () {
            this.load()
        },
        methods: {
            setTime(time){
                var date = new Date(time);
                var month = date.getMonth() + 1
                var day =  date.getDate()
                var hours =   date.getHours()
                var minutes = date.getMinutes()
                var datese = date.getSeconds()
                if(datese /1  < 10){
                    datese = '0' +  datese
                }
                if(month /1  < 10){
                    month = '0' +  month
                }
                if(day /1  < 10){
                    day = '0' +  day
                }
                if(hours /1  < 10){
                    hours = '0' +  hours
                }
                if(minutes /1  < 10){
                    minutes = '0' +  minutes
                }
                return date.getFullYear() + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + datese
            },
            pageSizes(val){
                this.pageSize = val
                this.loading = true
                this.load(1)
            },
            pageChange(index){
                this.initPage = index
                this.loading = true
                this.load (1)
            },
            load (index){
                let _this = this
                let params = new URLSearchParams()
                if(index == '1'){
                    _this.initPage = 1
                }
                params.append('page',_this.initPage)
                params.append('pageSize',_this.pageSize)
                params.append('sellerName',_this.sellerName)
                params.append('buyerName',_this.buyerName)
                if(_this.time){
                    params.append('time',_this.setTime(_this.time))
                }else{
                    params.append('time',_this.time)
                }
                params.append('count',_this.count)
                params.append('totalPrice',_this.totalPrice)
                $http.post('/backgroundTradeTour/findByPeople',params).then(function (res) {
                    if(res.suc){
                    _this.Message = res.result.rows
                    _this.loading = false
                    _this.pageNum = res.result.total
                }else{
                    if(res.msg == "请先登录"){
                        _this.$Message.error('请重新登录！');
                    }else{
                        _this.$Message.error(res.msg);
                    }
                }
                })
            }
        }
    }
</script>
<style>
    .ivu-form-item {
        margin-bottom: 5px;
    }
</style>

